# 元组的定义,元组与链表的区别为，元组中的元素不能改变

# t1 = (1,"Hello",True)
# t2 = ()
# t3 = tuple()
# print(f"t1的类型是:{type(t1)},内容是:{t1}")
#
# # 定义单个元素的元组
#
# t4 = ("Hello",) # 需要写一个单独的逗号
# print(f"t1的类型是:{type(t4)},内容是:{t4}")
#
# # 元组的嵌套与索引
# t5 = ((1,2,3),(4,5,6))
# print(f"t1的类型是:{type(t5)},内容是:{t5}")
# print(t5[1][1])

# 元组中嵌套了一个链表，是可以更改链表的内容的

# t1 = (1,2,[3,4,5])
# print(t1)
# t1[2][0] = 6
# t1[2].append(7)
# print(t1)






# 字符串

# replace函数

# Str = "Hello World"
# new_Str = Str.replace("Hello", "World")# 将Hello换成World
# print(new_Str)


# 字符串的分割

# Str = "Hello World"
# my_Str_list = Str.split(" ")# 转入以什么字符进行分割
# print(my_Str_list)


# 字符串的规整，函数strip

# Str = "       Hello World   "
# new_Str = Str.strip()# 不转参数，就去除首尾的空格
# print(new_Str)
#
# Str1 = "12Hello World21"
# new_Str1 = Str1.strip("12")# 可以去除子串
# print(new_Str1)


# 统计次数

# Str = "Hello World"
# count = Str.count("lo")
# print(count)





# 对list进行切片

# my_list = [1,2,3,4,5,6]
# result1 = my_list[1:4]
# print(result1)


#对tuple进行切片

# my_tuple = (1,2,3,4,5,6)
# result2 = my_tuple[:] # 起始与结束不写表示从头到尾，步长为1
# print(result2)


# 对str进行切片

# my_str = "01234567"
# result3 = my_str[::2]# 从头到尾，步长为2
# print(result3)





# 集合

# 集合不支持重复的元素，且无序所以不能索引，可以修改

# my_set = {"python","Holle","python"}
# my_set1 = {} # 定义空集合，也可以 变量 = set()
# print(my_set)
# print(my_set1)
# print(type(my_set))
#
# # 添加元素
# my_set.add("world")
# print(my_set)
#
# # 移除元素
# my_set.remove("python")
# print(my_set)
#
# # 随机取出一个元素，因为集合是无序的，所以用pop取指定下标时，无下标就会随机取
# my_set2 = {"python","Holle","world"}
# element = my_set2.pop()
# print(element)
#
# # 清空集合
# my_set2.clear()
# print(my_set2)
#
#
# # 差集
# set1 = {1,2,3}
# set2 = {1,4,5}
# set3 = set1.difference(set2)# set1里面有，set2中没有的
# print(set3)
#
#
# # 消除差集
# set1 = {1,2,3}
# set2 = {1,4,5}
# set1.difference_update(set2) # set1消除与set2相同的元素
# print(set1)
#
#
# # 集合的合并
# set1 = {1,2,3}
# set2 = {1,4,5}
# set3 = set1.union(set2)
# print(set3)
#
#
# # 集合的遍历,集合不支持下标索引，所以不能用while
# set1 = {1,2,3,4,5,6}
# for item in set1:
#     print(item)






# 字典,key是不可以重复的

# 定义
# my_dict = {"张三":99,"李四":88,"王五":77}
# my_dict2 = {}
# my_dict3 = dict()
# print(my_dict)
# print(my_dict2)
# print(my_dict3)
# print(type(my_dict))
#
#
# # 用key获取value
# print(my_dict["张三"])
# print(my_dict["李四"])
#
#
# # 定义嵌套字典
# stu_score_dict = {
#     "张三":{"语文":77,"数学":66,"英语":33},
#     "李四":{"语文":88,"数学":86,"英语":55}
# }
# print(stu_score_dict)
#
# score = stu_score_dict["张三"]["语文"]
# print(score)
#
# score = stu_score_dict["李四"]["数学"]
# print(score)




# 字典增加元素
# my_dict = {"name": "John", "age": 25}
# my_dict["sex"] = "man"
# print(my_dict)
#
# # 更新元素
# my_dict["age"] = 18
# print(my_dict)
#
# # 删除key，还是使用pop
# num = my_dict.pop("age")
# print(my_dict)
# print(num)
#
#
# #获取全部key
# my_dict = {"name": "John", "age": 25}
# Keys = my_dict.keys()
# print(Keys)
#
#
# # 遍历字典
#
# # 通过获得全部key来完成遍历
# for key in Keys:
#     print(f"{key} = {my_dict[key]}")
#
# #直接对字典进行for
# for key in my_dict:
#     print(f"{key} = {my_dict[key]}")






# sorted函数，返回一个链表

my_list = [1,5,2,3,5,4]
sorted_list = sorted(my_list)
print(sorted_list)
sorted_list = sorted(my_list,reverse=True)# 默认为false
print(sorted_list)

